﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace Script.UI.Component
{
    public class CutOnGivenValueSlider : HistogramDisplay
    {
        public Slider Sld_SmallThan;
        public Slider Sld_BigThan;
        public float Demarcation = 0;
       

        // Update is called once per frame
        void Update()
        {

        }

        public override void Display()
        {
            if (CurrentValue == Demarcation)
            {
                Sld_SmallThan.value = 0;
                Sld_BigThan.value = 0;
            }
            else if (CurrentValue > Demarcation)
            {
                float fPercent = 0;
                float fDifferenceValue = MaxValue - MinValue * 0.9f;
                if (fDifferenceValue - 0f < 0.00000001)
                {
                    fPercent = 0;
                }
                else
                {
                    fPercent = (Math.Abs(CurrentValue) - MinValue * 0.9f) / fDifferenceValue;
                }

                Sld_BigThan.value = fPercent;
                Sld_SmallThan.value = 0;

            }
            else
            {
                float fPercent = 0;
                float fDifferenceValue = MaxValue - MinValue * 0.9f;
                if (fDifferenceValue - 0f < 0.00000001)
                {
                    fPercent = 0;
                }
                else
                {
                    fPercent = (Math.Abs(CurrentValue) - MinValue * 0.9f) / fDifferenceValue;
                }

                Sld_BigThan.value = 0;
                Sld_SmallThan.value = fPercent;

            }
        }
    }
}
